package com.kun.gulimall.guliproduct.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kun.gulimall.guliproduct.domain.PmsBrand;
import com.kun.gulimall.guliproduct.query.BrandQuery;
import com.kun.gulimall.guliproduct.service.PmsBrandService;
import com.kun.gulimall.guliproduct.mapper.PmsBrandMapper;
import com.kun.gulimall.util.PageUtils;
import com.kun.gulimall.util.Query;
import org.springframework.stereotype.Service;

@Service
public class PmsBrandServiceImpl extends ServiceImpl<PmsBrandMapper, PmsBrand>
        implements PmsBrandService {

    @Override
    public boolean saveBrand(BrandQuery brandQuery) {
        PmsBrand pmsBrand = BeanUtil.copyProperties(brandQuery, PmsBrand.class);
        return save(pmsBrand);
    }

    @Override
    public boolean updateByBrandId(BrandQuery brandQuery) {
        PmsBrand pmsBrand = BeanUtil.copyProperties(brandQuery, PmsBrand.class);
        return updateById(pmsBrand);
    }

    @Override
    public PageUtils getBrandPage(BrandQuery brandQuery) {
        IPage<PmsBrand> paged = this.page(Query.getIBean(brandQuery, PmsBrand.class));
        return new PageUtils(paged);
    }
}




